import { ELogLevel } from "../common/ELogLevel";
import { DateEx } from "../../../LTGame/Utils/DateEx";

export class LTLogger {

    public logLevel: ELogLevel;

    public tag: string;

    constructor(tag: string, defaultLevel: ELogLevel) {
        this.logLevel = defaultLevel;
        this.tag = tag;
    }

    public Log(str: string, level: ELogLevel = ELogLevel.Log) {
        if (level < this.logLevel) {
            return;
        }
        let levelStr: string;
        switch (level) {
            case ELogLevel.Error:
                levelStr = "E"
                break;
            case ELogLevel.Log:
                levelStr = "I"
                break;
            case ELogLevel.Warn:
                levelStr = "W"
                break;
            case ELogLevel.Debug:
                levelStr = "D";
                break;
            default:
                levelStr = "undefine:" + level;
                break;
        }
        console.log(`[${levelStr}][${DateEx.GetTimeStr()}][${this.tag}]${str}`);
    }

}